import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

DateTime? _lastWillPopAt;
Duration delay = const Duration(seconds: 2);

extension ExtensionWidget on Widget {
  Widget get doubleExit => WillPopScope(
        child: this,
        onWillPop: () async {
          if (_lastWillPopAt == null || _lastWillPopAt != null && DateTime.now().difference(_lastWillPopAt!) > delay) {
            _lastWillPopAt = DateTime.now();
            // ToastUtils.toast("Press again to exit the app");
            return false;
          }
          return true;
        },
      );

  Positioned position({double? left,double? right,double? top,double? bottom}) => Positioned(left: left, right: right, top: top, bottom: bottom, child: this);
  Widget click(ontap) => InkWell(onTap:ontap,child:this);
}

extension ExColor on int {
  get color => Color(this);
}
